<%@ page language="java" import="weaver.general.Util" pageEncoding="UTF-8"%>
<%@ page import="java.text.ParseException" %>
<jsp:useBean id="recordSet" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="record" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page"/>

<%

//�������ݵķֲ�ID�������ֲ����ݶ�ɾ��
int subcompanyid = Util.getIntValue(request.getParameter("subcompanyid"),-1);
rs.writeLog("��ʼ����ɾ���ճ����ݽӿڣ���ηֲ� subcompanyid = "+subcompanyid);

if(subcompanyid > 0){

	try {
			String workplanids= "";
			//���ݷֲ���ȡ��Աid��Ȼ��ʹ����Աid��Ϊ�����˲�ѯ�ճ̣���ȡ�ճ�id��ɾ���ճ̱���ճ̹����
			recordSet.executeQuery("select id from hrmresource where subcompanyid1 <> "+ subcompanyid);
			while (recordSet.next()) {
				String hrmid = recordSet.getString("id");

				record.executeQuery("select id from workplan where 1=1 and createrid = ? ",hrmid);
				while (record.next()) {
					if("".equals(workplanids)){
						workplanids = record.getString("id");
					}else{
						workplanids += ","+record.getString("id");
					}
				}
				//�����ճ�idɾ���������ݺͲλ�������
				if(!"".equals(workplanids)){
					rs.executeUpdate("delete from workplan where id in("+workplanids+")");
					rs.executeUpdate("delete from WorkPlanShareDetail where workid in("+workplanids+")");
					rs.executeUpdate("delete from WorkPlanShare where workplanid in("+workplanids+")");
					rs.executeUpdate("delete from WorkPlanExchange where workplanid in("+workplanids+")");
					rs.executeUpdate("delete from Exchange_Info where type_n='WP' and sortid in("+workplanids+")");
				}
			}
			rs.writeLog("����ɾ���ճ����ݽӿڽ���");
			out.print("�ճ�ɾ������");
		} catch (ParseException e) {
			rs.writeLog("����ɾ���ճ����ݽӿ��쳣��");
			rs.writeLog("�쳣��Ϣ��"+e.getMessage());
		}

}

%>